package com.wenmingliang.ch01;

/**
 * @author wenmingliang
 * @create 2023/3/29
 */
public class Solution {
    /**
     * 进制转换
     * @param M int整型 给定整数
     * @param N int整型 转换到的进制
     * @return string字符串
     *
     * 给定一个十进制数，把他转换为指定的进制数
     */
    public static String solve (int M, int N) {
        // write code here
        StringBuilder builder = new StringBuilder();
        getString(M, N, builder);
        return builder.reverse().toString();
    }

    public static void getString (int M, int N, StringBuilder buider) {
        // write code here
        if (M != 0) {
            buider.append(M % N);
            M = M / N;
            getString(M, N, buider);
        }
        else {
            return;
        }

    }

    public static void main(String[] args) {
        System.out.println(solve(721,2));
    }

}